package main

import "fmt"

func main() {

	var arr = [3]int{1, 2, 3}
	fmt.Println(arr)

	arr1 := [3]int{1, 2, 3}
	fmt.Println(arr1[0])
	arr1[1] = 20
	fmt.Println(arr1[1])

	nums := []int{1, 2, 3}
	nums = append(nums, 4)
	fmt.Println(nums)
	fmt.Println("个数 -> ", len(nums))
	fmt.Println("容量 -> ", cap(nums))

	sums1 := arr[0:2]
	fmt.Println(sums1)

	ages := map[string]int{"one": 1, "two": 2, "three": 3}
	fmt.Println(ages)
	ages["four"] = 4
	fmt.Println(ages)
	for k, v := range ages {
		fmt.Println(k, v)
	}

	for k, v := range ages {
		fmt.Println(k, v)
	}
	delete(ages, "four")
	if val, exists := ages["four"]; exists {
		fmt.Println("存在，年龄 -> ", val)
	} else {
		fmt.Println("four 不存在")
	}

	//test()

	test2()
}
